package chapter12;

interface Strom {
    public void event() throws RainedOut;

    public void rainHard() throws RainedOut;
}

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/3/12 9:20
 */
class BaseballException extends Exception {

}

class Foul extends BaseballException {
}

class Strike extends BaseballException {
}

abstract class Inning {
    public Inning() throws BaseballException {
    }

    public void event() throws BaseballException {
    }

    public abstract void atBat() throws Strike, Foul;

    public void walk() {
    }

}

class StromException extends Exception {
}

class RainedOut extends StromException {
}

class PopFoul extends Foul {
}

public class StormyInning extends Inning implements Strom {

    /*@Override
    public void walk throws PopFoul() {

    }*/

    // 可以在构造器添加构造器，但是必须添加基类的异常
    public StormyInning() throws RainedOut, BaseballException {
    }

    //
    public StormyInning(String s) throws Foul, BaseballException {

    }

    public static void main(String[] args) {
        try {
            StormyInning si = new StormyInning();
            si.atBat();
        } catch (PopFoul popFoul) {
            popFoul.printStackTrace();
        } catch (BaseballException e) {
            e.printStackTrace();
        } catch (RainedOut rainedOut) {
            rainedOut.printStackTrace();
        }

        try {
            Inning inning = new StormyInning();
            inning.atBat();
        } catch (Strike strike) {
            strike.printStackTrace();
        } catch (Foul foul) {
            foul.printStackTrace();
        } catch (BaseballException e) {
            e.printStackTrace();
        } catch (RainedOut rainedOut) {
            rainedOut.printStackTrace();
        }
    }

    @Override
    public void event() {
    }

    @Override
    public void atBat() throws PopFoul {

    }

    @Override
    public void rainHard() throws RainedOut {

    }
}
